<template>
  <div class="role">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">主页</el-breadcrumb-item>
      <el-breadcrumb-item>安全管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色管理</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="my-query">
      <el-form :inline="true" size="mini" :model="query">
        <el-form-item label="状态">
          <el-select v-model="query.u_status" @change="changeStatus()">
            <el-option label="全部" value=""></el-option>
            <el-option
              v-for="item in userStatus"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="角色">
          <el-select v-model="query.ro_id" placeholder="全部" @change="changeRole()">
            <el-option label="全部" value=""></el-option>
            <el-option
              v-for="item in userStatus"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="账号">
          <el-input v-model="query.u_id"></el-input>
        </el-form-item>
        <el-form-item label="姓名">
          <el-input v-model="query.u_name"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="my-data">
      <el-table :data="list" style="width: 100%">
        <el-table-column prop="u_id" label="账号" ></el-table-column>
        <el-table-column prop="ro_id" label="角色" ></el-table-column>
        <el-table-column prop="u_status" label="状态"></el-table-column>
        <el-table-column prop="ro_remark" label="备注"></el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
          <!--<template slot-scope="scope">
            <el-button @click="handleClick(scope.row.u_id)" type="text" size="mini">重置</el-button>
          </template>-->
        </el-table-column>
      </el-table>
    </div>
    <div class="page">
      <el-pagination
        :page-sizes="[2,3,4,5]"
        layout="sizes,prev, pager, next,jumper, ->, total"
        :total="50"
      ></el-pagination>
    </div>
  </div>
</template>


<script>
export default {
  name: "Role",
  data() {
    return {
      //查询条件
      query:{
        u_status:'',
        u_id:'',
        u_name:'',
        ro_id:'',
      },
      //状态列表
      userStatus: [
        { value: "00", label: "未确定" },
        { value: "55", label: "已启用" },
        { value: "77", label: "已禁用" }
      ],
      // userRoles:[
      //     {value:`${ro_id}`,label:`${ro_name}`}
      // ],
      //用户数据列表
      list:[],
    };
  },
  methods: {
    //获取用户列表
    getPage(){
      // this.$myGet('safty/role')
      // .then(roleList=>{
      //   this.roleList=roleList;
      //   }) axios封装方法使用错误
      this.$axios.get('safty/role')
      .then(response=>{
        this.list = response.data;
      })
    },

    changeStatus(){
      console.log("改变查询状态~")
    },
    changeRole(){
      console.log("改变查询角色~")
    },
  },
  mounted() {
    this.getPage();
  }
};
</script>
<style scoped>
.role {
  width: 100%;
  height: 100%;
  position: relative;
}
.my-query {
  position: absolute;
  text-align: left;
  left: 0px;
  top: 30px;
  width: 100%;
  height: 50px;
}
.my-data {
  position: absolute;
  left: 0px;
  top: 80px;
  width: 100%;
}
.page {
  position: absolute;
  width: 100%;
  left: 0px;
  bottom: 0px;
}
</style>